package hojadetrabajo4;

public class singlyLinkedList<E> extends abstractList<E>
{

   protected int count; // list size
   protected nodo<E> head; // ref. to first element

   public singlyLinkedList()
   // post: generates an empty list
   {
      head = null;
      count = 0;
   }
   
   public int size()
   // post: returns number of elements in list
  {
    return count;
  }
  
  public void push(E value)
    {
// note order that things happen:
// head is parameter, then assigned
    head = new nodo<E>(value, head);
    count++;
    }

   
      public E pop()
        {
            nodo<E> temp = head;
            head = head.next(); // move head down list
            count--;
            return temp.value();
        }
  

        @Override
        public boolean isEmpty() {
            return size()==0;
        }

        @Override
        public void clear() {
            head=null;
            count=0;
        }

        @Override
        public E peek() {
            return head.value();
    }
}